package edu.hhu.wifispark.entry;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

public class BasePhone extends Model<BasePhone>{
	private static final long serialVersionUID = 1L;
	public final static BasePhone dao = new BasePhone();
	
	public BasePhone countNew(){
		String sql = "SELECT  atime , count(*) AS count from basephone WHERE atime = (SELECT MAX(atime) from basephone)";
		return findFirst(sql);
	}
	public List<BasePhone> findToday(long stime,long etime){
		String sql = "SELECT * FROM basephone WHERE atime > "+stime +" AND atime < "+etime+"  ORDER BY mac,atime";
		System.out.println(sql);
		return find(sql);
//		return null;
	}
	public List<BasePhone> findNowPeople(){
		String sql = "SELECT  * from basephone WHERE atime = (SELECT MAX(atime) from basephone)";
		return find(sql);
	}
	
	public List<BasePhone> findCoorFrom(long stime){
		String sql ="SELECT * FROM basephone WHERE atime > "+stime+" AND `inner` = 1";
		return find(sql);
	}
	
	public List<BasePhone> findTodayOrder(long stime,long etime){
		String sql = "SELECT * FROM basephone WHERE atime > "+stime +" AND atime < "+etime + " ORDER BY mac,atime";
		return find(sql);
	}
}
